<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  website
 */

class m_website_actions_block_DeleteWebsiteAction extends m_backoffice_extends_FormModal
{
	public function execute()
	{
		$website = f_document_Provider::getInstance()->getByModelAndUniqueId('website/Website', $this->getRequestParameter("docId"), $this->getRequestParameter("docLang"));

		$messages = array();
		if(count($website->getAllLangs()) > 1 && !$website->isATranslation())
		{
			$messages[] = $this->getLocale('website.errors.deleteWebsite');
		}

		$this->addToModel("messages", $messages);
		$this->addToModel("website", $website);
		$this->addToModel("href", $this->getRequestParameter("href"));
		
		$this->setView('success');
	}	
	
	public function validate()
	{
		return $this->getUserContext()->hasRight(array("backoffice_accessBo", "website_Delete"));
	}
}